import React from 'react'
import {  BrowserRouter, Route ,Switch,Redirect} from 'react-router-dom'
import Login from '../views/login/Login'
import NewsSandBox from '../views/newsSandBox/NewsSandBox'

export default function IndexRouter() {
  return <BrowserRouter>
  <Switch>
      <Route path='/login' component={Login}></Route>
      <Route
          path="/"
          render={() => {
           return localStorage.getItem("token") ? (
              <NewsSandBox></NewsSandBox>
            ) : (
              <Redirect to="./login"></Redirect>
            );
          }}
        ></Route>
  </Switch>
</BrowserRouter>
}
